package com.mrx.xfriendship.converter;

import com.mrx.xfriendship.model.dto.CommentDTO;
import com.mrx.xfriendship.model.po.CommentPO;
import com.mrx.xfriendship.model.vo.CommentVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingConstants;

/**
 * @author Mr.X
 * @since 2023-01-15 09:49
 */
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, uses = OtherConverter.class)
public interface CommentConverter extends IConverter<CommentPO, CommentDTO> {

    @Override
    @Mapping(target = "publishTime", source = "createTime")
    @Mapping(target = "content", expression = "java( commentPO.getContent() )")
    CommentDTO toDTO(CommentPO commentPO);

    @Mapping(target = "postId", expression = "java( postId )")
    @Mapping(target = "createUserId", expression = "java( userId )")
    @Mapping(target = "content", expression = "java( vo.getContent() )")
    CommentPO toPO(Integer postId, Integer userId, CommentVO vo);

}
